package com.fnzn.entranceGuard.util;

import lombok.extern.slf4j.Slf4j;

/**
 * @author wf_sxf@163.com
 * @date 2018-08-17 10:43
 */
@Slf4j
public enum WeekEnum {
    Monday("01","Mon"),//星期1
    Tuesday("02","星期二"),//星期二
    Wednesday("03","星期三"),
    Thursday("04","星期四"),Friday("05","星期五"),Saturday("06","星期六"),Sunday("07","星期日");

     WeekEnum( String name,String code) {
        this.code = code;
        this.name = name;
    }
    private String code;

    private String name;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    /**
     * 根据code的值获取name。
     *
     * @param code 活动状态的值
     * @return 枚举对象
     */
    public static String getNameByCode(String code) {
        WeekEnum[] allStatus = WeekEnum.values();
        for (WeekEnum ws : allStatus) {
            if (ws.getCode().equalsIgnoreCase(code)) {
                return ws.getName();
            }
        }
        log.error("code: "+code+"  非法，没有符合关系类型的枚举对象");
        return "01";

       // throw new IllegalArgumentException("");
    }
}
